<?php 
   if( $this->ts_functions->getsettings('portal','revenuemodel') != 'subscription' ) {
	   $spurDetail = $this->DatabaseModel->access_database('ts_purchaserecord','select','',array('purrec_prodid'=>$productdetails[0]['prod_id']));
	   $sprod_sale=count($spurDetail);
   }else{
	  $sprod_sale=$productdetails[0]['prod_download_count']; 
   }
   $svendorName = $this->ts_functions->getVendorName($productdetails[0]['prod_uid']);
   $svendor_url=base_url().'vendor/'.$svendorName;
   
   
  

?>
<div class="tp_page_title">
	<div class="container">
		<div class="row">
			<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
				<div class="tp_page_heading">
					<h3><?php echo $productdetails[0]['prod_name'];?></h3>
				</div>
			</div>
		</div>
	</div>
</div>
<div class="tp_gray_wrapper tp_toppadder80 tp_bottompadder80">
	<div class="container">
		<div class="row">
			<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
				<div class="tp_comment">
					 <h3 class="ts_post_topic"><?php echo $this->ts_functions->getlanguage('commentstext','singleproductpage','solo');?> (<?php echo $comment_count; ?>)</h3> 
					<?php if(!empty($comments_list)) { ?>
					<ol class="comment">
					<?php foreach($comments_list as $parent_comment){ ?>
						<?php 
						 $parent_image_src= base_url().'webimage/dummy_testi.jpg';
							if($parent_comment['user_pic']!=""){
							$parent_image_src=base_url().'webimage/'.$parent_comment['user_pic'];
							}
						 ?>
						
						<li class="comment-list ts_postbox">
							<div class="tp_author_img">
								<img src="<?php echo $parent_image_src ; ?>" class="img-responsive" alt="">
							</div>
							<div class="tp_comment_data">
								<h2><?php echo $parent_comment['user_uname'];  ?></h2>
								<h5><?php echo time_elapsed_string($parent_comment['comment_date']); ?></h5>
								<p><?php echo $parent_comment['comment_text'];  ?></p>
								<a onclick="repy_form(<?php echo $parent_comment['comment_id'] ?>,this)" class="tp_reply"><i class="fa fa-reply"></i> <?php echo $this->ts_functions->getlanguage('replay','commontext','solo');?></a>
							</div>
							<?php 
							$child_comments=$this->ts_functions->get_child_comments($parent_comment['comment_id']);
							if(!empty($child_comments)){
							?>
							<ul class="children">
							 <?php foreach($child_comments as $child_comment){ ?>
							  <?php $child_image_src= base_url().'webimage/dummy_testi.jpg';
								if($child_comment['user_pic']!=""){
								$child_image_src=base_url().'webimage/'.$child_comment['user_pic'];
								}
								?>
								<li class="comment-list">
									<div class="tp_author_img">
										<img src="<?php echo $child_image_src; ?>" class="img-responsive" alt="">
									</div>
									<div class="tp_comment_data">
										<h2><?php echo $child_comment['user_uname'];  ?></h2>
										<h5><?php echo time_elapsed_string($child_comment['comment_date']); ?></h5>
										<p><?php echo $child_comment['comment_text'];  ?></p>
									</div>
								</li>
							 <?php } ?>
							</ul>
							<?php } ?>
							<div class="ts_cmntrplybox hide" id="ts_cmntrplybox">
									
							</div>
						</li>
					<?php } ?>	
					</ol>
					<?php } ?>
					<div class="hide" id="reply_form_div">
						   <div class="form-group">
						   <input type="hidden" id="product_id" value="<?php echo $productdetails[0]['prod_id'];?>">
							<textarea class="form-control validate" rows="6" placeholder="<?php echo $this->ts_functions->getlanguage('replay','commontext','solo');?>" id="msg"></textarea>
							</div>
							<a href="javascript:" onclick="" class="tp_btn" id="reply_to_main_a"><?php echo $this->ts_functions->getlanguage('post','commontext','solo');?> <i class="fa fa-paper-plane" aria-hidden="true"></i></a>
				   </div>
				</div>
				<?php if(isset($this->session->userdata['ts_uid'])) {
                 $vName = $this->ts_functions->getVendorName($this->session->userdata['ts_uid']);
  				?>
				<div class="tp_comment_form">
					<h3><?php echo $this->ts_functions->getlanguage('postnew','commontext','solo');?></h3>
					<form>
						<div class="row">
							<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
								<div class="form-group">
									<textarea class="form-control" rows="5" placeholder="<?php echo $this->ts_functions->getlanguage('yourmessage','commontext','solo');?>" id="newcomment_0"></textarea>
								</div>	
							</div>
							<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
								<button class="tp_btn" type="button" onclick="send_comment_post(<?php echo $productdetails[0]['prod_id'];?>,0)"><?php echo $this->ts_functions->getlanguage('post','commontext','solo');?></button>
							</div>
						</div>
					</form>
				</div>
				<?php } ?>
			</div>
			<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
				<div class="tp_sidebar">
					<div class="tp_sidebar_div tp_text_content">
						<h3><?php echo $this->ts_functions->getlanguage('licenseheading','singleproductpage','solo');?></h3>
						<p><?php echo $this->ts_functions->getlanguage('licensesubheading','singleproductpage','solo');?></p>
						<div class="tp_btndiv">
							<?php if( $productdetails[0]['prod_free'] == '0') {
                                if( $this->ts_functions->getsettings('portal','revenuemodel') != 'subscription' ) { ?>

                                    <a href="<?php echo $basepath;?>shop/add_to_cart/products/<?php echo $productdetails[0]['prod_uniqid'];?>" class="tp_btn"> <?php echo $this->ts_functions->getlanguage('addtocart','homepage','solo');?> </a>

                                    <a href="<?php echo $basepath;?>shop/add_to_cart/products/<?php echo $productdetails[0]['prod_uniqid'];?>" class="tp_btn"> <?php echo $this->ts_functions->getlanguage('buynowtab','homepage','solo');?> - <?php echo $this->ts_functions->getsettings('portalcurreny','symbol');?><?php echo $productdetails[0]['prod_price'];?> </a>

                                <?php } else { ?>
                                    <a href="<?php echo $basepath;?>shop/checkmembership/<?php echo $productdetails[0]['prod_uniqid'];?>" class="tp_btn"> <?php echo $this->ts_functions->getlanguage('buynowtab','homepage','solo');?> </a>
							<?php   }
							    } else {
							        // Free
							    ?>
							        <a href="<?php echo $basepath;?>shop/add_to_cart/products/<?php echo $productdetails[0]['prod_uniqid'];?>" class="tp_btn"> <?php echo $this->ts_functions->getlanguage('freetext','commontext','solo');?></a>

							<?php } ?>
						</div>
					</div>
					<div class="tp_sidebar_div">
						<h3><?php echo $this->ts_functions->getlanguage('productheading','singleproductpage','solo');?></h3>
						<div class="tp_author_detail">
							<img src="<?php echo $basepath.'webimage/'.$this->ts_functions->getVendorPic($productdetails[0]['prod_uid']);?>" alt="<?php echo $svendorName;?>" title="<?php echo $svendorName;?>">
							<h4><a href="<?php echo $svendor_url ?>"><?php echo $svendorName; ?></a></h4>
						</div>
						<div class="tp_product_info">
							<p><strong><?php echo $this->ts_functions->getlanguage('createsubheading','singleproductpage','solo');?></strong> : <?php echo date_format(date_create ( $productdetails[0]['prod_date'] ) , 'M d, Y');?></p>
							<p><strong><?php echo $this->ts_functions->getlanguage('updateddatetext','singleproductpage','solo');?></strong> : <?php echo date_format(date_create ( $productdetails[0]['prod_update'] ) , 'M d, Y');?></p>
							
							<p>
							<?php $rating_count = $rating_count[0]['tot_stars'];?>					
							<strong><?php echo $this->ts_functions->getlanguage('ratingssubheading','singleproductpage','solo');?>
							</strong>
							<span><i class="fa fa-star<?php echo ($rating_count < 1) ? '-o' : '' ; ?>"></i></span>
							<span><i class="fa fa-star<?php echo ($rating_count < 2) ? '-o' : '' ; ?>"></i></span>
							<span><i class="fa fa-star<?php echo ($rating_count < 3) ? '-o' : '' ; ?>"></i></span>
							<span><i class="fa fa-star<?php echo ($rating_count < 4) ? '-o' : '' ; ?>"></i></span>
							<span><i class="fa fa-star<?php echo ($rating_count < 5) ? '-o' : '' ; ?>"></i></span>
							</p>
							<p><strong><?php echo $this->ts_functions->getlanguage('commentstext','singleproductpage','solo');?></strong> : <?php echo $comment_count;?> <a href="<?php echo $com_url; ?>"><i class="fa fa-comment"></i></a></p>
							<p><strong><?php echo $this->ts_functions->getlanguage('downloadssubheading','singleproductpage','solo');?></strong> : <?php echo $sprod_sale; ?></p>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>